<template>
	<!-- myset账户与折扣设置 -->
	<view class="wp">
		<uni-forms ref="form" label-width="400px" label-position="top" :modelValue="dataInfo">
			<uni-forms-item label="优惠买单是否核销(不含团购核销)" required>
				<uni-data-checkbox v-model="dataInfo.ischeckorder" :localdata="checkbox1" />
			</uni-forms-item>
		</uni-forms>
		<view class="" style="text-align: center;">
			<button class="fbt" @click="submit">提交</button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				uid: '',
				dataInfo: {
					ischeckorder: '',
				},
				checkbox1: [{
						text: '手动核销收款',
						value: '1'
					},
					{ 
						text: '自动核销收款',
						value: '0'
					}
				],
				rules: {},
			}
		},
		onReady() {
			this.$refs.form.setRules(this.rules)
		},
		onLoad(options) {
			this.uid = options.uid;
			this.getInfo();
		},
		methods: {
			getInfo() {
				this.$axios('info/checkOrderInfo', 'POST', 'supplier', {
					uid: this.uid
				}).then(res => {
					if (res.data.code == 200) {
						this.dataInfo = res.data.data;
					}
				})
			},
			submit() {
				this.$refs.form.validate().then(res => {
					let obj = {
						...this.dataInfo,
						uid: this.uid,
						status: this.dataInfo.ischeckorder
					}
					this.$axios('info/checkOrder', 'POST', 'supplier', obj).then(res => {
						if (res.data.code == 200) {
							this.$api.msg('设置成功！');
						}
					})
				}).catch(err => {
					console.log('err', err);
				})
			}
		}
	}
</script>

<style lang="scss">
	.wp {
		padding: 20upx;
	}

	.message {
		color: #4399fc;
		font-size: 24upx;
	}

	.sub {
		background: #18bc37;
		color: #fff;
		font-size: 28upx;
		line-height: 80upx;
		width: 90%;
	}
</style>